home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
smaltalk
/
st80_pr4.lha
/
st80_pre4
/
MoDE
/
TestSNA-Lin.st
< prev
next >
Wrap
Text File
|
1993-07-24
|
38KB
|
1,594 lines
SemanticObject subclass: #BoxCreatorButton
instanceVariableNames: ''
classVariableNames: 'SNABoxMiddleButtonMenu '
poolDictionaries: ''
category: 'TestSNA-Lin'!
!BoxCreatorButton methodsFor: 'MMS-initializations'!
defaultMMSControllerClass
"Shan March 9, 1990"
^PushButtonController!
setUpAppearance
"Shan March 9, 1990"
mode borderWidth: 2.
mode insideColor: Form white.
mode extent: 30 @ 30.
mode highlightDispObj: #inverseHighlight! !
!BoxCreatorButton methodsFor: 'controller-msg'!
action: e
"Ask the user for a rectangle then use that to create the box. Shan
March 4, 1990"
| rect box |
EventQ waitNoButton.
EventQ disable.
rect _ Rectangle fromUser.
EventQ enable.
box _ SNARectangle new.
box attachModeTo: target1 mode.
box mode setUnclippedDisplayBox: rect.
box mode borderWidth: 1.
box getName.
box mode display! !
SemanticObject subclass: #SNATreeNode
instanceVariableNames: 'title parent children leftNeighbor posX posY posP posM '
classVariableNames: 'DefaultVal NodeSize SNATreeNodeMiddleButtonMenu '
poolDictionaries: ''
category: 'TestSNA-Lin'!
!SNATreeNode methodsFor: 'access'!
children
^children!
children: e
children addLast: e.!
leftNeighbor
^leftNeighbor!
leftNeighbor: aNode
leftNeighbor _ aNode!
modifier
^posM!
modifier: val
posM _ val!
parent
^parent!
parent: val
parent _ val!
posX
^posX!
posX: val
posX _ val.!
posY
^posY!
posY: val
posY _ val.!
prelim
^posP!
prelim: val
posP _ val! !
!SNATreeNode methodsFor: 'middleMenu support'!
addNode
"29 May 1990"
| m name dispObj nameOffset e anode |
e _ mode controller event.
anode _ SNATreeNode new.
EventQ disable.
FillInTheBlank
request: 'Type a name. '
displayAt: e origin
centered: true
action: [:resp | name _ resp]
initialAnswer: ''.
self children: anode.
anode target1: target1.
anode parent: self.
SNATree new positionTree.
anode attachModeTo: target1 mode at: anode posX @ anode posY.
m _ anode mode.
Cursor wait
showWhile:
[dispObj _ m displayObject.
nameOffset _ 2 @ 2.
dispObj relAdd: (name asDisplayText offset: nameOffset). "m unclippedDisplayBox extent > dispObj boundingBox extent
ifFalse: [m setUnclippedDisplayBoxExtent: dispObj
boundingBox extent + (nameOffset + m borderWidth * 2)]."
"m display."
self treeDisplay.
EventQ enable]! !
!SNATreeNode methodsFor: 'menu access'!
middleButtonMenu
| logicMenu |
SNATreeNodeMiddleButtonMenu isNil
ifTrue:
[logicMenu _ MMSMenu new.
logicMenu append: (MenuCell selector: #addNode text: 'Add Child').
logicMenu append: (MenuCell selector: #inspect text: 'Inspect').
logicMenu append: (MenuCell selector: #hExpand text: 'Follow Hypertext Link').
SNATreeNodeMiddleButtonMenu _ MMSPopUpMenu createInterfaceFor: logicMenu].
^SNATreeNodeMiddleButtonMenu! !
!SNATreeNode methodsFor: 'MMS-initializations'!
defaultMMSControllerClass
"Shan March 9, 1990"
^MidMenuAndMoveController!
setUpAppearance
"29 May 1990"
super setUpAppearance.
mode extent: 20 @ 20.
mode borderWidth: 1.
mode insideColor: Form white.
mode highlightDispObj: #thickBorderHighlight! !
!SNATreeNode methodsFor: 'initialize-release'!
initialize
super initialize.
children _ OrderedCollection new.
parent _ nil.
leftNeighbor _ nil.
posY _ 200.
posX _ 0.
posP _ 0.
posM _ 0.! !
!SNATreeNode methodsFor: 'layout-support'!
leftSibling
"29 May 1990"
| brothers |
parent isNil ifTrue: [^nil].
brothers _ parent children.
self == brothers first
ifTrue: [^nil]
ifFalse: [^brothers before: self]!
rightSibling
"29 May 1990"
| brothers |
parent isNil ifTrue:[^nil].
brothers _ parent children.
self = brothers last
ifTrue: [^nil]
ifFalse: [^brothers after: self]!
treeDisplay
"29 May 1990"
RootNode attachModeTo: target1 mode at: RootNode posX @ RootNode posY.
RootNode children do: [:each | self treeDisplay: each].
target1 mode erase.
target1 mode display!
treeDisplay: aNode
"29 May 1990"
aNode children isEmpty
ifTrue: [aNode attachModeTo: target1 mode at: aNode posX @ aNode posY]
ifFalse: [aNode children do: [:each | self treeDisplay: each]]! !
SemanticObject subclass: #SNAGraph
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'TestSNA-Lin'!
SNAGraph comment:
'"SNAWorkSpace new" will return the semantic object of the backgrounds mode where all the boxes and links reside. Shan March 9, 1990.
Choose menu by clicking in the function button area:
1. Save to file.
2. redisplay all object in this diagram.
This is designed for IBM SNA Diagram:
.. Decomposition
.. Flow'!
!SNAGraph methodsFor: 'MMS-initializations'!
defaultMMSControllerClass
"Shan March 9, 1990"
^MidMenuController!
defaultModeClass
"Shan March 9, 1990"
^ExpandedMode!
setUpController
super setUpController!
setUpMode
"Shan March 9, 1990"
super setUpMode.
mode window: (20 @ 20 extent: 480 @ 400).
mode resizeStyle: ResizeStyle stickFourCorners! !
!SNAGraph methodsFor: 'initialize-release'!
initialize
"Initialize the buttons that create the contents of SNA decomposition
diagram. Lin Mar 5, 1990"
| tmp amode aSemObj wind sBar rs |
super initialize. "Shan March 9, 1990"
amode _ ExpandedMode new.
aSemObj _ SemanticObject new.
tmp _ BoxCreatorButton new.
tmp target1: aSemObj.
tmp attachModeTo: amode at: 0 @ 0.
tmp _ PointCreatorButton new.
tmp target1: aSemObj.
tmp attachModeTo: amode at: 0 @ 100.
tmp _ PathCreatorButton appearance: (MDisplayObject new absAdd: MMSOpaqueForm trash)
pathClass: MMPolyline.
tmp target1: aSemObj.
tmp attachModeTo: amode at: 0 @ 30.
rs _ ResizeStyle new.
rs originY: #fixed.
rs originX: #fixed.
rs extentX: #fixed.
rs cornerY: #fixed.
rs matchViewportWindow: true.
amode borderWidth: 0.
amode resizeStyle: rs.
wind _ mode window.
sBar _ RoamBox extent: 20 @ (wind height - 16) clientMode: aSemObj mode.
sBar attachModeTo: mode at: wind right - sBar mode viewport width @ wind top.
rs _ ResizeStyle new.
rs originY: #fixed.
rs extentX: #fixed.
rs cornerX: #fixed.
rs cornerY: #fixed.
sBar mode resizeStyle: rs.
sBar _ RoamBox extent: wind width - 16 - 45 @ 18 clientMode: aSemObj mode.
rs _ ResizeStyle new.
rs originX: #fixed.
rs extentY: #fixed.
rs cornerX: #fixed.
rs cornerY: #fixed.
sBar mode resizeStyle: rs.
sBar attachModeTo: mode at: 65 @ (wind bottom - sBar mode viewport height).
aSemObj mode borderWidth: 1.
aSemObj mode resizeStyle: ResizeStyle stickFourCorners.
mode
addSubMode: amode
at: 20 @ 20
extent: 45 @ mode viewport height.
mode
addSubMode: aSemObj mode
at: 65 @ 20
extent: mode viewport width - 45 @ mode viewport height - 18! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
SNAGraph class
instanceVariableNames: ''!
!SNAGraph class methodsFor: 'testing'!
prototest1
"SNAGraph prototest1"
"Linjs, Feb. 25, 1990"
| rMode w |
rMode _ RootMode new.
rMode label: 'MMS Application'.
rMode minimumSize: 700 @ 630.
w _ SNAWindow title: 'SNA' origin: 150@50 extent: 500 @ 400.
w shrinkPosition: 20@20.
w applicationMode: (SNAGraph new) mode.
w attachModeTo: rMode.
rMode startUp!
prototest2
"SNAWorkSpace prototest2"
"Linjs, Feb. 25, 1990"
| aFileName tmp |
aFileName := FillInTheBlank request: 'Load SNA materials from file' initialAnswer: ''.
aFileName = ''
ifTrue:
[self prototest1.
^nil].
Cursor read showWhile: [tmp := BinaryStorage fromFileNamed: aFileName].
tmp startUp! !
SemanticObject subclass: #PointCreatorButton
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'TestSNA-Lin'!
!PointCreatorButton methodsFor: 'controller-msg'!
action: e
"16 May 1990"
| pt position |
pt _ SNAPoint new.
EventQ waitNoButton.
Cursor crossHair showWhile: [position _ EventQ waitClickButton grid: SEESharedStates gridPoint].
pt attachModeTo: target1 mode.
pt mode setUnclippedDisplayBoxOrigin: position.
pt mode display! !
!PointCreatorButton methodsFor: 'MMS-initializations'!
defaultMMSControllerClass
"Shan March 9, 1990"
^PushButtonController!
setUpAppearance
"Shan March 9, 1990"
mode borderWidth: 2.
mode insideColor: Form gray.
mode extent: 30 @ 30.
mode highlightDispObj: #inverseHighlight! !
SemanticObject subclass: #SNATree
instanceVariableNames: ''
classVariableNames: 'LevelPtr SNATreeMiddleButtonMenu SubtreeSeparation XTopAdjustment YTopAdjustment '
poolDictionaries: ''
category: 'TestSNA-Lin'!
!SNATree methodsFor: 'layout'!
apportion: aNode level: aLevel
"28 May 1990"
| leftmost neighbor depth ancLeftmost ancNeighbor lModsum rModsum i moveD tempP leftsib portion |
leftmost _ aNode children first.
neighbor _ leftmost leftNeighbor.
depth _ 1.
[leftmost isNil or: [neighbor isNil]]
whileFalse:
[lModsum _ 0.
rModsum _ 0.
ancLeftmost _ leftmost.
ancNeighbor _ neighbor.
i _ depth.
[i < 0]
whileFalse:
[ancLeftmost _ ancLeftmost parent.
ancNeighbor _ ancNeighbor parent.
ancLeftmost isNil ifFalse: [rModsum _ rModsum + ancLeftmost modifier].
ancNeighbor isNil ifFalse: [lModsum _ lModsum + ancNeighbor modifier].
i _ i - 1].
moveD _ neighbor prelim + lModsum + 40 + 20 - (leftmost prelim + rModsum).
moveD > 0
ifTrue:
[tempP _ aNode.
leftsib _ 0.
[tempP isNil or: [tempP == ancNeighbor]]
whileFalse:
[leftsib _ leftsib + 1.
tempP _ tempP leftSibling].
tempP isNil
ifFalse:
[portion _ moveD / leftsib.
tempP _ aNode.
[tempP = ancNeighbor]
whileTrue:
[tempP prelim: tempP prelim + moveD.
tempP modifier: tempP modifier + moveD.
moveD _ moveD - portion.
tempP _ tempP leftSibling]]
ifTrue: [^self]].
depth _ depth + 1.
leftmost children isEmpty
ifTrue: [leftmost _ self
getLeftmost: aNode
level: 1
depth: depth + 1]
ifFalse: [leftmost _ leftmost children first]]!
firstWalk: aNode level: aLevel
"29 May 1990"
| midPoint leftmost rightmost |
LevelPtr size < aLevel
ifTrue: [LevelPtr addLast: aNode]
ifFalse:
[aNode leftNeighbor: (LevelPtr at: aLevel).
LevelPtr at: aLevel put: aNode].
aNode modifier: 0.
aNode children isEmpty
ifTrue: [aNode leftSibling isNil ifFalse: [aNode prelim: aNode leftSibling prelim + 40 + 20]
ifTrue: [aNode prelim: 0]]
ifFalse:
[leftmost _ rightmost _ aNode children first.
self firstWalk: leftmost level: aLevel + 1.
[rightmost rightSibling isNil]
whileFalse:
[rightmost _ rightmost rightSibling.
self firstWalk: rightmost level: aLevel + 1].
midPoint _ leftmost prelim + rightmost prelim / 2.
aNode leftSibling isNil
ifFalse:
[aNode prelim: aNode leftSibling prelim + 40 + 20.
aNode modifier: aNode prelim - midPoint.
self apportion: aNode level: aLevel]
ifTrue: [aNode prelim: midPoint]]!
getLeftmost: aNode level: aLevel depth: depth
"28 May 1990"
| rightmost leftmost |
aLevel >= depth
ifTrue: [^aNode]
ifFalse: [aNode children isEmpty
ifTrue: [^nil]
ifFalse:
[rightmost _ aNode children first.
leftmost _ self
getLeftmost: rightmost
level: aLevel + 1
depth: depth.
[leftmost isNil and: [rightmost rightSibling ~= nil]]
whileTrue:
[rightmost _ rightmost rightSibling.
leftmost _ self
getLeftmost: rightmost
level: aLevel + 1
depth: depth].
^leftmost]]!
positionTree
LevelPtr _ OrderedCollection new.
self firstWalk: RootNode level: 1.
YTopAdjustment _ RootNode posY + RootNode prelim.
XTopAdjustment _ RootNode posX.
self secondWalk: RootNode level: 1 offset: 0.!
positionTree: aNode
LevelPtr _ OrderedCollection new.
self firstWalk: aNode level: 1.
YTopAdjustment _ aNode posY + aNode prelim.
XTopAdjustment _ aNode posX.
self secondWalk: aNode level: 1 offset: 0.!
secondWalk: aNode level: aLevel offset: modsum
"24 May 1990"
aNode posY: YTopAdjustment - (aNode prelim + modsum).
aNode posX: XTopAdjustment + (aLevel -1 * 30).
aNode children isEmpty ifFalse: [self
secondWalk: aNode children first
level: aLevel + 1
offset: modsum + aNode modifier].
aNode rightSibling isNil ifFalse: [self
secondWalk: aNode rightSibling
level: aLevel
offset: modsum]! !
!SNATree methodsFor: 'initialize-release'!
initialize
super initialize.
LevelPtr _ OrderedCollection new.! !
!SNATree methodsFor: 'middleMenu support'!
createTree
"29 May 1990"
| m name dispObj nameOffset e |
e _ mode controller event.
RootNode _ SNATreeNode new.
EventQ disable.
FillInTheBlank
request: 'Type a name. '
displayAt: e origin
centered: true
action: [:resp | name _ resp]
initialAnswer: ''.
RootNode target1: self.
self positionTree: RootNode.
mode addSubMode: RootNode mode at: (RootNode posX)@(RootNode posY).
m _ RootNode mode.
Cursor wait
showWhile:
[dispObj _ m displayObject.
nameOffset _ 2 @ 2.
dispObj relAdd: (name asDisplayText offset: nameOffset).
"m unclippedDisplayBox extent > dispObj boundingBox extent ifFalse: [m setUnclippedDisplayBoxExtent: dispObj boundingBox extent + (nameOffset + m borderWidth * 2)].
"
m display.
EventQ enable].! !
!SNATree methodsFor: 'menu access'!
middleButtonMenu
| logicMenu |
SNATreeMiddleButtonMenu isNil
ifTrue:
[logicMenu _ MMSMenu new.
logicMenu append: (MenuCell selector: #createTree text: 'Create Tree').
logicMenu append: (MenuCell selector: #inspect text: 'Inspect').
logicMenu append: (MenuCell selector: #hExpand text: 'Follow Hypertext Link').
SNATreeMiddleButtonMenu _ MMSPopUpMenu createInterfaceFor: logicMenu].
^SNATreeMiddleButtonMenu! !
!SNATree methodsFor: 'MMS-initializations'!
defaultMMSControllerClass
"Shan March 9, 1990"
^MidMenuAndMoveController!
setUpController
"Shan March 9, 1990"
| d |
super setUpController.
d _ mode controller eventResponses deepCopy. "Shan March 30, 1990"
d at: #leftButtonDown put: #gridMove:.
mode controller eventResponses: d! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
SNATree class
instanceVariableNames: ''!
!SNATree class methodsFor: 'test'!
demo
"SNATree demo"
"29 May 1990"
| rMode w |
rMode _ RootMode new.
rMode label: 'MMS Application'.
rMode minimumSize: 700 @ 630.
w _ SNAWindow title: 'SNA' origin: 150@50 extent: 500 @ 400.
w shrinkPosition: 20@20.
w applicationMode: (SNATree new) mode.
w attachModeTo: rMode.
rMode startUp! !
SemanticObject subclass: #MPolyline
instanceVariableNames: 'arrowStatus '
classVariableNames: 'MPolylineMiddleButtonMenu '
poolDictionaries: ''
category: 'TestSNA-Lin'!
MPolyline comment:
'The instance var "arrowStatus" can be:
#none -- no arrow
#begin -- arrow at the beginning
#end -- arrow at the end
#both -- arrow at both ends.
Shan March 7, 1990'!
!MPolyline methodsFor: 'editing'!
checkDots: pt
"Do the reshaping and return true when pt falls on one of the dots.
Otherwise, return false. Shan March 3, 1990"
| ptCltn index anchorPts newPt |
ptCltn _ self absPointCltn.
ptCltn do: [:each | (each - pt) abs <= (2 @ 2) ifTrue: [index _ ptCltn indexOf: each]].
index isNil
ifFalse:
["Check for boundary"
anchorPts _ OrderedCollection new.
index = 1
ifTrue: [anchorPts add: (ptCltn at: 2)]
ifFalse:
[anchorPts add: (ptCltn at: index - 1).
index = ptCltn size ifFalse: [anchorPts add: (ptCltn at: index + 1)]]. "reshape"
newPt _ mode controller
rubberLineOriginCltn: anchorPts
within: nil
releaseSelectors: (OrderedCollection with: #leftButtonUp)
gridPoint: SEESharedStates gridPoint. "Shan March 16, 1990"
ptCltn at: index put: newPt. "Shan March 7, 1990"
self eraseReshapeDots.
mode erase.
self absPointCltn: ptCltn.
mode display.
self showReshapeDots.
^true]
ifTrue: [^false]!
eraseReshapeDots
"Shan March 3, 1990"
self showReshapeDots!
showReshapeDots
"Shan March 3, 1990"
| rect |
self absPointCltn do:
[:each |
rect _ each - (2@2) extent: 5@5.
Display reverse: rect]! !
!MPolyline methodsFor: 'controller-msg'!
action: e
"Put up the reshape dots and move image. Shan March 3, 1990"
| active event |
mode controller moveImage.
self showReshapeDots.
active _ true.
[active]
whileTrue:
[event _ EventQ nextWithCursorMoveCompressed.
event selector == #leftButtonDown ifTrue: ["Check dots"
(self checkDots: event origin)
ifFalse: ["Check move"
(mode interestedIn: event)
ifTrue:
[self eraseReshapeDots.
mode controller moveImageGridTo: SEESharedStates gridPoint
. "Shan March 19, 1990" self showReshapeDots]
ifFalse: ["terminate"
active _ false]]]].
self eraseReshapeDots.
"self buildLine: self absPointCltn."! !
!MPolyline methodsFor: 'middleMenu support'!
hExpand
"Expand the hypertext link. Shan March 20, 1990"
| pView aPollingEnvMode w |
pView _ SNATextView "Shan April 2, 1990"
on: (SNAText fileName: 'SNAdoc/text1')
aspect: #text
change: #acceptText:from:
menu: #textMenu.
pView borderWidth: (1@1 corner: 1@1). "Shan March 21, 1990"
aPollingEnvMode _ PollingEnvMode new "extent: 450 @ 200".
aPollingEnvMode addSubView: pView.
w _ SNAWindow
title: 'Path Control'
origin: 30 @ 275
extent: 500 @ 300.
w shrinkPosition: 20 @ 220.
w applicationMode: aPollingEnvMode.
w attachModeTo: mode topMode.
w initialOpen.
Display zoom: mode unclippedDisplayBox to: w mode unclippedDisplayBox.
w mode display! !
!MPolyline methodsFor: 'menu access'!
middleButtonMenu
"Shan March 20, 1990"
| logicMenu |
MPolylineMiddleButtonMenu isNil
ifTrue:
[logicMenu _ MMSMenu new.
logicMenu append: (MenuCell selector: #hExpand text: 'Follow Hypertext Link').
MPolylineMiddleButtonMenu _ MMSPopUpMenu createInterfaceFor: logicMenu].
^MPolylineMiddleButtonMenu! !
!MPolyline methodsFor: 'MMS-initializations'!
defaultModeClass
"Shan February 26, 1990"
^FixedImageMode!
setUpController
"Shan March 20, 1990"
| ctrl erDict |
super setUpController.
ctrl _ mode controller.
erDict _ ctrl eventResponses deepCopy.
erDict at: #leftButtonDown put: #action:.
erDict at: #middleButtonDown put: #expandMiddleMenu.
ctrl eventResponses: erDict! !
!MPolyline methodsFor: 'formating'!
absPointCltn: aCltnOfPts
"The points are in screen coordinates. This can only be used when
superMode exists. Shan February 1990"
| bBox |
bBox _ self buildLine: aCltnOfPts.
mode setUnclippedDisplayBoxOrigin: bBox origin!
brushForm
^SEESharedStates brushForm.!
brushForm: aForm
SEESharedStates brushForm: aForm.!
buildLine: aCltnOfPts
"Set up the display object and return the bounding box for the
polyline. All points in the path will be translated relative to the
bounding box of the path. The bounding box is returned. Shan
February 26, 1990"
| dispObj line bBox arrowForm vector |
dispObj _ mode displayObject.
dispObj clear.
line _ MMSLinearFit new.
line form: self brushForm.
aCltnOfPts do: [:each | line add: each].
bBox _ line boundingBox.
dispObj absAdd: line.
arrowStatus == #end
ifTrue:
["Arrows. Shan March 7, 1990"
vector _ aCltnOfPts last - (aCltnOfPts before: aCltnOfPts last).
arrowForm _ MMSOpaqueForm arrows closestAtVector: vector.
dispObj absAdd: arrowForm.
arrowForm offset: aCltnOfPts last - 8.
bBox _ bBox merge: arrowForm boundingBox].
dispObj translateBy: bBox origin * -1.
dispObj makeAbsoluteFaster.
^bBox!
pointCltn: aCltnOfPts
"The points are relative to the will-be superMode. Shan February 26,
1990"
| bBox |
bBox _ self buildLine: aCltnOfPts.
mode origin: bBox origin extent: bBox extent! !
!MPolyline methodsFor: 'accessing'!
absPointCltn
"Return the collection of points that form the polyline in screen
coordinates. This works only when this polyline has a rootMode.
Shan February 26, 1990"
| line cltn dBoxOrg |
line _ mode displayObject contents first.
cltn _ OrderedCollection new.
dBoxOrg _ mode unclippedDisplayBox origin.
1 to: line size do: [:n | cltn add: (line at: n)
+ dBoxOrg].
^cltn!
arrowStatus
"Shan March 7, 1990"
^arrowStatus!
arrowStatus: aSymbol
"Shan March 7, 1990"
arrowStatus _ aSymbol! !
!MPolyline methodsFor: 'initialize-release'!
initialize
"Shan March 7, 1990"
super initialize.
arrowStatus _ #none! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
MPolyline class
instanceVariableNames: ''!
!MPolyline class methodsFor: 'testing'!
test1
"self test1"
"Shan March 3, 1990"
| rMode bt |
rMode _ RootMode new.
bt _ PathCreatorButton appearance: (MDisplayObject new absAdd: MMSOpaqueForm trash) pathClass: MPolyline.
bt attachModeTo: rMode at: 10@10.
rMode semanticObject: SemanticObject new.
bt target1: rMode semanticObject.
rMode startUp!
test2
"self test2"
"Shan March 3, 1990"
| rMode bt |
rMode _ RootMode new.
bt _ PathCreatorButton appearance: (MDisplayObject new absAdd: MMSOpaqueForm trash) pathClass: MMPolyline.
bt attachModeTo: rMode at: 10@10.
rMode semanticObject: SemanticObject new.
bt target1: rMode semanticObject.
rMode startUp! !
MPolyline subclass: #MMPolyline
instanceVariableNames: 'lineWidth lineColor '
classVariableNames: 'SNAMMPolyMiddleButtonMenu '
poolDictionaries: ''
category: 'TestSNA-Lin'!
!MMPolyline methodsFor: 'MMS-initializations'!
defaultMMSControllerClass
"Shan March 3, 1990"
^MidMenuController! !
!MMPolyline methodsFor: 'initialize-release'!
initialize
""
super initialize.
arrowStatus _ #none.
lineWidth _ 1.
lineColor _ Form black.! !
!MMPolyline methodsFor: 'attribute support'!
black
""
| |
lineColor _ Form black.!
darkGray
lineColor _ Form darkGray.!
four
""
| |
lineWidth _ 4.
mode erase.
self buildLine: self absPointCltn.
mode display.!
gray
lineColor _ Form gray.!
lightGray
lineColor _ Form lightGray.!
one
""
| |
lineWidth _ 1.
mode erase.
self buildLine: self absPointCltn.
mode display.!
three
""
| |
lineWidth _ 3.
mode erase.
self buildLine: self absPointCltn.
mode display.!
two
""
| |
lineWidth _ 2.
mode erase.
self buildLine: self absPointCltn.
mode display.!
veryDarkGray
lineColor _ Form veryDarkGray.!
veryLightGray
lineColor _ Form veryLightGray.!
white
lineColor _ Form white.!
zero
""
| |
lineWidth _ 0.
mode erase.
self buildLine: self absPointCltn.
mode display.! !
!MMPolyline methodsFor: 'menu-support'!
changeArrow
self arrowStatus == #none
ifTrue: [self arrowStatus: #end]
ifFalse: [self arrowStatus: #none].
mode erase.
self buildLine: self absPointCltn.
mode display.!
editLineColor
MenuTestWorkSpace colorMapMenu startUpOnSemanticObject: self.
self buildLine: self absPointCltn.
mode erase.
mode display.!
hCreate
"Shan 31 May 1990"
SNACurrentStates
startLinkFrom: self
at: mode unclippedDisplayBox center
rootMode: mode topMode!
hExpand
"Shan 31 May 1990"
SNACurrentStates expandLinkFrom: self sourceBox: mode unclippedDisplayBox!
removeLine
self clearAllConnections.
mode erase.
mode removeFromSuperMode.
mode release!
resizeLine
| active event |
"mode controller moveImage."
self showReshapeDots.
active _ true.
[active]
whileTrue:
[event _ EventQ nextWithCursorMoveCompressed.
event selector == #leftButtonDown ifTrue: ["Check dots"
(self checkDots: event origin)
ifFalse: ["Check move"
(mode interestedIn: event)
ifTrue:
[self eraseReshapeDots.
mode controller moveImageGridTo: SEESharedStates gridPoint.
self showReshapeDots]
ifFalse: ["terminate"
active _ false. ]]]].
self eraseReshapeDots.
self buildLine: self absPointCltn.! !
!MMPolyline methodsFor: 'menu access'!
middleButtonMenu
| logicMenu subM |
SNAMMPolyMiddleButtonMenu isNil
ifTrue:
[logicMenu _ MMSMenu new.
logicMenu append: (MenuCell selector: #changeArrow text: 'Change Arrow').
logicMenu append: (MenuCell selector: #editLineColor text: 'Line Color').
logicMenu append: (subM _ MenuCell selector: nil text: 'Line Width').
subM append: MenuTestWorkSpace lineWidthLogicMenu.
logicMenu append: (MenuCell selector: #resizeLine text: 'Reshape').
logicMenu append: (MenuCell selector: #removeLine text: 'Remove').
logicMenu append: (MenuCell selector: #hExpand text: 'Follow Hypertext Link').
logicMenu append: (MenuCell selector: #hCreate text: 'Create Hypertext Link'). SNAMMPolyMiddleButtonMenu _ MMSPopUpMenu createInterfaceFor: logicMenu].
^SNAMMPolyMiddleButtonMenu! !
!MMPolyline methodsFor: 'formating'!
buildLine: aCltnOfPts
"Set up the display object and return the bounding box for the
polyline. All points in the path will be translated relative to the
bounding box of the path. The bounding box is returned. Shan
February 26, 1990"
| dispObj line bBox arrowForm vector aForm |
dispObj _ mode displayObject.
dispObj clear.
line _ MMSLinearFit new.
aForm _ Form new extent: lineWidth asPoint.
aForm black.
line form: aForm.
line color: lineColor.
aCltnOfPts do: [:each | line add: each].
bBox _ line boundingBox.
dispObj absAdd: line.
arrowStatus == #end
ifTrue:
["Arrows. Shan March 7, 1990"
vector _ aCltnOfPts last - (aCltnOfPts before: aCltnOfPts last).
arrowForm _ MMSOpaqueForm arrows closestAtVector: vector.
dispObj absAdd: arrowForm.
arrowForm offset: aCltnOfPts last - 8 .
bBox _ bBox merge: arrowForm boundingBox].
dispObj translateBy: bBox origin * -1.
dispObj makeAbsoluteFaster.
^bBox! !
!MMPolyline methodsFor: 'accessing'!
absPointCltn
"Return the collection of points that form the polyline in screen
coordinates. This works only when this polyline has a rootMode.
Shan February 26, 1990"
| line cltn dBoxOrg |
line _ mode displayObject contents first.
cltn _ OrderedCollection new.
dBoxOrg _ mode unclippedDisplayBox origin.
1 to: line size do: [:n | cltn add: (line at: n)
+ dBoxOrg].
^cltn!
displayLine: aCltnOfPts
| subdispObj sourcePt vector arrowForm bBox |
mode erase.
subdispObj _ MDisplayObject new.
sourcePt _ nil.
aCltnOfPts do:
[:each |
sourcePt isNil ifFalse: [subdispObj absAdd: (MMSLine
from: sourcePt
to: each
width: lineWidth
color: lineColor)].
sourcePt _ each].
bBox _ subdispObj boundingBox.
arrowStatus == #end
ifTrue:
["Arrows. Shan March 7, 1990"
vector _ aCltnOfPts last - (aCltnOfPts before: aCltnOfPts last).
arrowForm _ MMSOpaqueForm arrows closestAtVector: vector.
subdispObj absAdd: arrowForm.
arrowForm offset: aCltnOfPts last - 8.
bBox _ bBox merge: arrowForm boundingBox].
subdispObj displayAt: bBox origin.! !
SemanticObject subclass: #SNAPoint
instanceVariableNames: 'filled position '
classVariableNames: 'SNAPointMiddleButtonMenu '
poolDictionaries: ''
category: 'TestSNA-Lin'!
!SNAPoint methodsFor: 'menu access'!
middleButtonMenu
| logicMenu |
SNAPointMiddleButtonMenu isNil
ifTrue:
[logicMenu _ MMSMenu new.
"logicMenu append: (MenuCell selector: #editMode text: 'Change Appearance').
" logicMenu append: (MenuCell selector: #remove text: 'Remove').
" logicMenu append: (MenuCell selector: #hExpand text: 'Follow Hypertext Link')."
SNAPointMiddleButtonMenu _ MMSPopUpMenu createInterfaceFor: logicMenu].
^SNAPointMiddleButtonMenu! !
!SNAPoint methodsFor: 'menu-support'!
editMode
| circle |
mode erase.
mode removeFromSuperMode.
circle _ MMSCircle new.
filled == #yes ifTrue: [ filled _ #no.
circle form: (Form extent: 1 @ 1) black.
circle radius: 3.
circle center: 3 @ 3.
]
ifFalse: [ filled _ #yes.
circle form: (Form extent: 2 @ 2) black.
circle radius: 1.
circle center: 3 @ 3.].
mode displayObject absAdd: circle.
"mode erase."
mode display.!
remove
self clearAllConnections.
mode erase.
mode removeFromSuperMode.
mode release! !
!SNAPoint methodsFor: 'MMS-initializations'!
defaultMMSControllerClass
"16 May 1990"
^MidMenuAndMoveController!
setUpController
"Shan March 9, 1990"
| d |
super setUpController.
d _ mode controller eventResponses deepCopy. "Shan March 30, 1990"
d at: #leftButtonDown put: #gridMove:.
mode controller eventResponses: d!
setUpMode
"SNAPoint setUpMode"
super setUpMode.
mode extent: 7@7! !
!SNAPoint methodsFor: 'initialize-release'!
initialize
| circle |
super initialize.
filled _ #no.
circle _ MMSCircle new.
circle form: (Form extent: 1 @ 1) black.
circle radius: 3.
circle center: 3 @ 3.
mode displayObject absAdd: circle.! !
!SNAPoint methodsFor: 'access'!
position: aPoint
position _ aPoint! !
!SNAPoint methodsFor: 'controller-msg'!
gridMove: e
"Shan March 19, 1990"
mode controller moveImageGridTo: SEESharedStates gridPoint! !
SemanticObject subclass: #PathCreatorButton
instanceVariableNames: 'pathClass '
classVariableNames: 'SharedBrushForm '
poolDictionaries: ''
category: 'TestSNA-Lin'!
PathCreatorButton comment:
'The mode is the button on the pallet that shows the icon of the path. When the button is clicked, this semantic object collect a set of point for creating the path. Shan March 3, 1990'!
!PathCreatorButton methodsFor: 'point collecting'!
getPtCltn
"This is the main method. It interacts with the user and provides
feedback. Shan March 3, 1990"
| ptCltn prePt newPt |
Cursor crossHair
showWhile:
[ptCltn _ OrderedCollection new. "Get the first point"
"Shan March 16, 1990"
ptCltn add: (EventQ waitClickButton grid: SEESharedStates gridPoint).
["Collect the rest of the point"
prePt _ ptCltn last.
newPt _ mode controller
rubberLineOriginCltn: (OrderedCollection with: prePt)
within: nil
releaseSelectors: (OrderedCollection with: #leftButtonDown)
gridPoint: SEESharedStates gridPoint.
newPt ~= prePt
ifTrue:
[ptCltn add: newPt.
Display
drawLine: PathCreatorButton sharedBrushForm
from: prePt
to: newPt
clippingBox: Display boundingBox
rule: Form over
mask: Form black].
newPt ~= prePt] whileTrue].
^ptCltn! !
!PathCreatorButton methodsFor: 'controller-msg'!
action: e
"Enter the point collection mode. Shan March 3, 1990"
| ptCltn path |
ptCltn _ self getPtCltn.
path _ pathClass new.
path arrowStatus: #end.
"target1 mode is the background of the path."
path attachModeTo: target1 mode.
path absPointCltn: ptCltn.
path mode display! !
!PathCreatorButton methodsFor: 'MMS-initializations'!
defaultMMSControllerClass
"Shan March 9, 1990"
^PushButtonController!
setUpAppearance
"Shan March 9, 1990"
mode highlightDispObj: #inverseHighlight! !
!PathCreatorButton methodsFor: 'private'!
appearance: aDispObj pathClass: aClass
"Shan March 3, 1990"
pathClass _ aClass.
mode displayObject: aDispObj.
mode resizeToFitDisplayObject! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
PathCreatorButton class
instanceVariableNames: ''!
!PathCreatorButton class methodsFor: 'instance creation'!
appearance: aDispObj pathClass: aClass
"Create the button that when pushed, generate an instance of the
path. 'target1' is the destination mode's semantic object. Shan
March 3, 1990"
^self new appearance: aDispObj pathClass: aClass! !
!PathCreatorButton class methodsFor: 'accessing'!
sharedBrushForm
"Shan March 3, 1990"
^SharedBrushForm!
sharedBrushForm: aForm
"Shan March 3, 1990"
SharedBrushForm _ aForm! !
!PathCreatorButton class methodsFor: 'class initialization'!
initialize
"self initialize"
"Shan March 3, 1990"
SharedBrushForm _ (Form new extent: 1@1) black.! !
PathCreatorButton initialize!
TextLabel subclass: #SNARectangle
instanceVariableNames: 'centeredText '
classVariableNames: 'SNARecMiddleButtonMenu '
poolDictionaries: ''
category: 'TestSNA-Lin'!
!SNARectangle methodsFor: 'menu-support'!
centerText
mode erase.
self centerText1: text.
mode display.
centeredText _ #yes!
duplicateBox
| newProto newProtoMode newPos |
Cursor wait
showWhile:
[newProto _ self duplicate.
newProto attachModeTo: mode superMode absAt: EventQ mousePoint - (newProto mode displayBox extent / 2).
newProtoMode _ newProto mode.
newProtoMode display].
newPos _ newProtoMode controller moveImageFB.
newPos notNil
ifTrue:
[newProto attachModeTo: mode superMode absAt: newPos.
newProtoMode display]!
editBorderColor
borderOrinside _ #borderColor:.
MenuTestWorkSpace colorMapMenu startUpOnSemanticObject: self.
mode erase.
mode display!
editInsideColor
"Shan July 31, 1989"
borderOrinside _ #insideColor:.
MenuTestWorkSpace colorMapMenu startUpOnSemanticObject: self.
mode erase.
mode display!
editName
self getName.
mode erase.
mode superView display.!
hCreate
"Shan 29 May 1990"
SNACurrentStates
startLinkFrom: self string
at: mode unclippedDisplayBox center
rootMode: mode topMode!
hExpand
"Expand the hypertext link. Shan March 20, 1990"
"Shan 29 May 1990"
SNACurrentStates expandLinkFrom: self string sourceBox: mode unclippedDisplayBox!
remove
self clearAllConnections.
mode erase.
mode removeFromSuperMode.
mode release!
resizeBox
mode controller bottomRightMoved.
ceteredText == #yes ifTrue:[self centerText1: text].
mode erase.
mode display! !
!SNARectangle methodsFor: 'attribute support'!
black
""
mode perform: borderOrinside with: Form black!
darkGray
""
mode perform: borderOrinside with: Form darkGray!
four
mode borderWidth: 4.
mode display!
gray
"Shan July 31, 1989"
mode perform: borderOrinside with: Form gray!
lightGray
""
mode perform: borderOrinside with: Form lightGray!
one
mode borderWidth: 1.
mode display!
three
mode borderWidth: 3.
mode display!
transparent
"Shan July 31, 1989"
borderOrinside = #borderColor: ifTrue: [^self].
mode perform: borderOrinside with: nil!
two
mode borderWidth: 2.
mode display!
veryDarkGray
""
mode perform: borderOrinside with: Form veryDarkGray!
veryLightGray
""
mode perform: borderOrinside with: Form veryLightGray!
white
""
mode perform: borderOrinside with: Form white!
zero
mode borderWidth: 0.
mode display! !
!SNARectangle methodsFor: 'MMS-initializations'!
defaultMMSControllerClass
"Shan March 9, 1990"
^MidMenuAndMoveController!
setUpController
"Shan March 9, 1990"
| d |
super setUpController.
d _ mode controller eventResponses deepCopy. "Shan March 30, 1990"
d at: #leftButtonDown put: #gridMove:.
mode controller eventResponses: d! !
!SNARectangle methodsFor: 'controller-msg'!
gridMove: e
"Shan March 19, 1990"
mode controller moveFrameGridTo: SEESharedStates gridPoint! !
!SNARectangle methodsFor: 'access'!
centerText1: aText
| aParagraph |
text _ aText.
"messageView _ DisplayTextView new editParagraph: aText asParagraph.
messageView borderWidthLeft: 0 right: 0 top: 0 bottom: 0.
messageView insideColor: Form white.
messageView controller: NoController new.
mode addSubView: messageView.
messageView centered."
"messageView translateBy: (mode inverseDisplayTransform: mode insetDisplayBox origin)."
mode displayObject clear.
aParagraph _ text asParagraph.
mode displayObject absAdd: (aParagraph align: aParagraph boundingBox center
with: self mode getWindow center).!
centerText: aText
| displayText |
text _ aText.
displayText _ aText asDisplayText.
mode displayObject clear.
mode displayObject relAdd: displayText.
self checkSize!
checkSize
mode resizeToFitDisplayObject! !
!SNARectangle methodsFor: 'attribute'!
getName
| newBlank aText fillinView savedArea aParagraph |
newBlank _ FillInTheBlank new initialize.
newBlank action: [:answer | aText _ answer].
fillinView _ SpecialFTBlankView
on: newBlank
message: 'box name'
displayAt: Sensor cursorPoint
centered: true
useCRController: false.
savedArea _ Form fromDisplay: fillinView displayBox.
EventQ disable.
fillinView window: (0 @ 0 extent: 200 @ 100).
fillinView display.
fillinView controller centerCursorInView.
fillinView controller startUp.
fillinView release.
EventQ enable.
savedArea displayOn: Display at: fillinView viewport topLeft.
centeredText == #yes
ifTrue: [self centerText1: aText]
ifFalse:
[text _ aText.
mode displayObject clear.
aParagraph _ text asParagraph.
mode displayObject absAdd: aParagraph]! !
!SNARectangle methodsFor: 'menu access'!
middleButtonMenu
| logicMenu mEditM subM |
SNARecMiddleButtonMenu isNil
ifTrue:
[logicMenu _ MMSMenu new.
logicMenu append: (MenuCell selector: #duplicateBox text: 'Duplicate').
logicMenu append: (MenuCell selector: #centerText text: 'Center Text').
logicMenu append: (MenuCell selector: #editName text: 'Edit Name').
logicMenu append: (mEditM _ MenuCell selector: #editMode text: 'Edit Appearance').
mEditM append: (MenuCell selector: #editInsideColor text: 'Inside Color').
mEditM append: (MenuCell selector: #editBorderColor text: 'Border Color').
mEditM append: (subM _ MenuCell selector: nil text: 'Border Width').
subM append: MenuTestWorkSpace lineWidthLogicMenu.
mEditM append: (MenuCell selector: #resizeBox text: 'Resize').
logicMenu append: (MenuCell selector: #remove text: 'Remove').
logicMenu append: (MenuCell selector: #hExpand text: 'Follow Hypertext Link').
logicMenu append: (MenuCell selector: #hCreate text: 'Create Hypertext Link').
SNARecMiddleButtonMenu _ MMSPopUpMenu createInterfaceFor: logicMenu].
^SNARecMiddleButtonMenu! !
!SNARectangle methodsFor: 'initialize-release'!
initialize
super initialize.
centeredText _ #no.! !
Object subclass: #SEESharedStates
instanceVariableNames: ''
classVariableNames: 'BrushForm GridPoint '
poolDictionaries: ''
category: 'TestSNA-Lin'!
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
SEESharedStates class
instanceVariableNames: ''!
!SEESharedStates class methodsFor: 'access'!
brushForm
"Shan April 3, 1990"
BrushForm isNil ifTrue: [BrushForm _ (Form extent: 2@2) black].
^BrushForm!
brushForm: aForm
"Shan April 3, 1990"
BrushForm _ aForm!
gridPoint
"Shan March 19, 1990"
GridPoint isNil ifTrue: [GridPoint _ 10 @ 10].
^GridPoint!
gridPoint: pt
"Shan March 19, 1990"
GridPoint _ pt! !